﻿@{
    Layout = "~/Views/Shared/_Index.cshtml";
}

<form>
    <div class="panel panel-default">
        <div class="panel-heading navb-bg">
            筛选条件
        </div>
        <table class="form">
            <tr>
                <th class="formTitle">关键字：</th>
                <td class="formValue">
                    <input id="txt_keyword" type="text" class="form-control form-an" placeholder="姓名/病历号/门诊号">
                </td>
                <th class="formTitle">结算日期：</th>
                <td class="formValue" colspan="2">
                    <input id="kssj" type="text" class="form-control input-wdatepicker" style="width:42%; float:left;" value="@DateTime.Now.AddMonths(-6).ToString("yyyy-MM-dd")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />
                    <span style="margin-left:1%;float:left">—</span>
                    <input id="jssj" type="text" class="form-control input-wdatepicker" style="width:43%; float:left;margin-left:1%;" value="@DateTime.Now.ToString("yyyy-MM-dd")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />
                </td>
                <th class="formTitle" style="height: 35px;"></th>
                <td class="formValue" style="padding-top: 1px;">
                    <div class="ckbox">
                        <input id="containsTF" name="containsTF" type="checkbox" checked="checked"><label for="containsTF">含退费</label>
                    </div>
                </td>
                <td class="formValue">
                    <input type="button" id="btn_search" class="btn btn-primary" style="width:36%;margin-left: 10%;" value="查询" />
                </td>
                <th class="formTitle"></th>
                <td class="formValue"></td>
            </tr>
        </table>
    </div>
    <div class="gridPanel">
        <table id="gridList"></table>
        <div id="gridPager"></div>
    </div>
</form>
@Html.Partial("_BottomButtonsView", new Newtouch.HIS.Web.Core.Models.BottomButtonViewModel()
{
    ShowKeyList = new int[] { 9 },
    F9Text = "导出Excel",
})

<script>
    $(function () {
        initControl();
        gridList();
    })

    var gridOptins = {
        url: "/OutpatientManage/Settlement/GetSettlementGridJson",
        height: $(window).height() - 185,
        postData: getSearchPostData(),
        colModel: [
            { label: '门诊号', name: 'mzh', width: 105, align: 'left', key: true },
            { label: 'blh', name: 'blh', hidden: true },
            { label: 'jsnm', name: 'jsnm', hidden: true },
            { label: '姓名', name: 'xm', width: 50, align: 'left' },
             {
                 label: '性别', name: 'xb', width: 35, align: 'center', formatter: function (cellvalue) {
                     return $.getGender(cellvalue);
                 }
             },
            { label: '费用性质', name: 'brxzmc', width: 60, align: 'left' },
            { label: '第一诊断', name: 'zdmc', width: 100, align: 'left' },
             {
                 label: '结算状态', name: 'jszt', width: 50, align: 'center', formatter: function (cellvalue) {
                     return cellvalue == 2 ? "退费" : (cellvalue == 1 ? "收费" : "");
                 }
             },
            {
                label: '结算日期', name: 'jsrq', width: 80, align: 'left',
                formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' }
            },
            { label: '发票号', name: 'fph', width: 100, align: 'left' },
            {
                label: '总金额', name: 'jszje', width: 60, align: 'left', formatter: moneyFormat
            },
            {
                label: '现金支付', name: 'jsxjzf', width: 60, align: 'left', formatter: moneyFormat
            },
            { label: '现金支付方式', name: 'zffsmcstr', width: 80, align: 'left' },
            {
                label: '医保一般费用', name: 'YBFY', width: 80, align: 'left', formatter: moneyFormat
            },
            {
                label: '基本账户支付', name: 'JBZF', width: 80, align: 'left', formatter: moneyFormat
            },
            {
                label: '公补账户支付', name: 'GBZF', width: 80, align: 'left', formatter: moneyFormat
            },
        ],
        pager: "#gridPager",
        rowNum: 10,
        sortname: 'jsrq desc',
        viewrecords: true
    };

    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid(gridOptins);
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: getSearchPostData(),
                page: 1,
            }).trigger('reloadGrid');
        });
    }

    function getSearchPostData() {
        return { keyword: $("#txt_keyword").val(), kssj: $("#kssj").val(), jssj: $("#jssj").val(), containsTF: $("#containsTF").is(":checked") };
    }

    function moneyFormat(cellvalue, a, b) {
        var str = cellvalue ? cellvalue.toFixed(2) : "0.00";
        if (b.jszt && b.jszt == '2' && parseFloat(cellvalue) > 0) {
            str = '-' + str;
        }
        return str;
    }

    //回车事件
    $('#txt_keyword').keydownEnterEvent(function () {
        $('#btn_search').trigger('click');
    })

    $('#containsTF').click(function () {
        setTimeout("$('#btn_search').trigger('click');", 100);
    });

    function initControl() {

    }

    var exportCols = null;
    function newtouch_event_f9() {
        exportCols = new Array();
        $.each(gridOptins.colModel, function () {
            if (!(this.hidden === true)) {
                exportCols.push({ Heading: this.label, Name: this.name, Width: this.width });
            }
        });
        Export();
    }

    function Export() {
        var url = "/OutpatientManage/Settlement/SettlementExportExcel?r=" + Math.random();
        url += "&keyword=" + $('#txt_keyword').val();
        url += "&kssj=" + $('#kssj').val();
        url += "&jssj=" + $('#jssj').val();
        url += "&containsTF=" + $("#containsTF").is(":checked");
        url += "&colStanWidth=" + "70";  //列宽度标准列
        var cols = JSON.stringify(exportCols);
        top.$.cookie('ExportExcelCols', cols, { path: "/" });
        //url += "&cols=" + encodeURIComponent(cols);

        window.open(url);
    }

</script>


